home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / unix / arcunx11 / arc.sh3 / arctst.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-01  |  1.6 KB  |  62 lines

  1. /*
  2.  *    arctst.c    1.1
  3.  *
  4.  *    Author: Thom Henderson
  5.  *    Original System V port: Mike Stump
  6.  *    Enhancements, Bug fixes, and cleanup: Chris Seaman
  7.  *    Date: Fri Mar 20 09:57:02 1987
  8.  *    Last Mod.    3/21/87
  9.  *
  10.  */
  11.  
  12. /*
  13.  * ARC - Archive utility - ARCTST
  14.  * 
  15.  * Version 2.12, created on 02/03/86 at 23:00:40
  16.  * 
  17.  * (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  18.  * 
  19.  *     Description:
  20.  *          This file contains the routines used to test archive integrity.
  21.  */
  22.  
  23. #include "arc.h"
  24.  
  25. INT tstarc()                           /* test integrity of an archive */
  26. {
  27.     struct heads hdr;                  /* file header */
  28.     long arcsize, ftell();             /* archive size */
  29.  
  30.     openarc(0);                        /* open archive for reading */
  31.     fseek(arc,0L,2);                   /* move to end of archive */
  32.     arcsize = ftell(arc);              /* see how big it is */
  33.     fseek(arc,0L,0);                   /* return to top of archive */
  34.  
  35.     printf("Testing archive...\n");
  36.     while (readhdr(&hdr,arc))
  37.     {
  38.         if (ftell(arc)+hdr.size>arcsize)
  39.         {
  40.             printf("Archive truncated in file %s\n",hdr.name);
  41.             nerrs++;
  42.             break;
  43.         }
  44.         else
  45.         {
  46.             printf("    File: %-14s  ",hdr.name);
  47.             fflush(stdout);
  48.             if (unpack(arc,NULL,&hdr))
  49.                 nerrs++;
  50.             else
  51.                 printf("okay\n");
  52.         }
  53.     }
  54.  
  55.     if (nerrs<1)
  56.         printf("No errors detected\n");
  57.     else if (nerrs==1)
  58.         printf("One error detected\n");
  59.     else
  60.         printf("%d errors detected\n",nerrs);
  61. }
  62.